package adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import androidx.viewpager.widget.PagerAdapter;

import java.text.ParseException;
import java.util.Date;
import utils.OtherUtil;

/**
 * ViewPager适配器
 * Create by: chenwei.li
 * Date: 2017/12/8
 * time: 15:17
 * Email: lichenwei.me@foxmail.com
 */

public class DatePagerAdapter2 extends PagerAdapter {

    private Context mContext;

    private int STYLE;//1.表示 "周"   2.表示"月"    3.表示"年"
    private CALL_BACK mCALL_BACK;
    public interface CALL_BACK{
        public void callBackData(int index);

    }
    public DatePagerAdapter2(Context context, int style,CALL_BACK mCALL_BACK) {
        this.mContext = context;
        this.STYLE = style;
        this.mCALL_BACK=mCALL_BACK;

    }

    public void setUpdateData(int style){
        this.STYLE = style;

    }


    @Override
    public int getCount() {
        return 0;
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {


//        String content=getDateData(STYLE,HealthBodyActivity.MAX_PAGE_COUNTS-1-position);
//        int chaZhi=HealthBodyActivity.MAX_PAGE_COUNTS-1-position;
//
//        if(mCALL_BACK!=null){
//            mCALL_BACK.callBackData(chaZhi);
//        }
//
//
//        if (STYLE == 2) {//月
//
//            DateMonthView dateView = new DateMonthView(mContext,content);
//            container.addView(dateView);
//            return dateView;
//
//        } else if (STYLE == 3) {//年
//
//            final DateYearView dateView = new DateYearView(mContext,content);
//            container.addView(dateView);
//            return dateView;
//
//        }
////       //周
//
//        DateWeekView ddd=new DateWeekView(mContext,content);
//        container.addView(ddd);
        return null;





    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {

        container.removeView((View) object);
    }


    /**
     * 当滑动view的时候，获取日期数据
     * @param style
     */
    private String  getDateData(int style,int se){
        String content=null;
        if(style==1){//周
            try {
                content = OtherUtil.getMondayToWeekdayByLastWeek(new Date(), se);
            } catch (ParseException e) {
                e.printStackTrace();
            }


        }else  if(style==2){//月
            content = OtherUtil.getMonthByCurrentTime(new Date(), se);
        }else  if(style==3){//年
            content = OtherUtil.getYear(new Date(), se);
        }

        return content;

    }


}
